package com.hq.es.config;


import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
* @author: lujie
* @create: 2021/4/10
* @description: 接口文档配置类
**/

@EnableOpenApi
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
@Configuration
public class Swagger3Config {

    @Bean
    public Docket docket() {

        return new Docket(DocumentationType.OAS_30)
                .groupName("Elasticsearch")
                .apiInfo(  builderApiInfo()  )
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.regex("(?!/error.*).*"))
                .build();
    }
    public ApiInfo builderApiInfo(){
        ApiInfo apiInfo = new ApiInfoBuilder()
                .contact(new Contact("lujie", "", "907298149@qq.com"))
                .description("Elasticsearch7.x 接口文档")
                .title("ElasticsearchApi")
                .version("1.0")
                .build();
        return apiInfo;
    }
}
